package jj.dao;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import jj.vo.CityFlightsVo;

@Service
public class CityFlightsService {

	private Map <String, CityFlightsVo> data = new HashMap<String, CityFlightsVo>();
	private long CACHE_TIME = 1000 * 60 * 3; /*3분*/
	
	@Autowired
	FlightDaoImpl flightDao;
	
	public CityFlightsVo getCityFlights(String date, String city){
		String key= generatingKey(date, city);
		CityFlightsVo vo = data.get(key);
		
		if(vo == null || vo.getUpdate_at() + CACHE_TIME < System.currentTimeMillis() ){
			//TODO: 실제로 access하자.
		}
		return vo;
	}
	
	public void setCityFlights(CityFlightsVo vo){
		setCityFlights(vo, false);
	}
	
	public void setCityFlights(CityFlightsVo vo, boolean update){
		
	}
	
	private String generatingKey(String date, String city){
		if(date == null || city == null || date =="" || city=="" )
			throw new NullPointerException();
		String key = date +"_"+city; 
		return key;
	}
}
